package com.easybbs.controller;

import com.easybbs.annotation.Globallnterceptor;
import com.easybbs.annotation.VerifyParam;
import com.easybbs.entity.enums.MessageStatusEnum;
import com.easybbs.entity.enums.MessageTypeEnum;
import com.easybbs.entity.enums.UserIntegralChangeTypeEnum;
import com.easybbs.entity.enums.UserIntegralOperTypeEnum;
import com.easybbs.entity.po.UserMessage;
import com.easybbs.entity.query.UserInfoQuery;
import com.easybbs.entity.vo.ResponseVO;
import com.easybbs.service.UserInfoService;
import com.easybbs.service.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/user")
public class UserInfoController extends BaseController {
    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private UserMessageService userMessageService;

    /**
     * 获取用户列表
     * @param userInfoQuery
     * @return
     */
    @RequestMapping("/loadUserList")
    @Globallnterceptor
    public ResponseVO loadUserList(UserInfoQuery userInfoQuery) {
        userInfoQuery.setOrderBy("join_time desc");
        return getSuccessResponseVO(userInfoService.findListByPage(userInfoQuery));
    }

    /**
     * 禁用用户状态
     * @param status
     * @param userId
     * @return
     */
    @RequestMapping("/updateUserStatus")
    @Globallnterceptor(checkParams = true)
    public ResponseVO updateUserStatus(@VerifyParam(required = true) Integer status, @VerifyParam(required = true) String userId) {
        userInfoService.updateUserStatus(status, userId);
        return getSuccessResponseVO(null);
    }

    /**
     * 发送系统消息
     * @param userId
     * @param message
     * @param integral
     * @return
     */
    @RequestMapping("/sendMessage")
    @Globallnterceptor(checkParams = true)
    public ResponseVO sendMessage(@VerifyParam(required = true) String userId,
                                  @VerifyParam(required = true) String message,
                                  Integer integral) {
        userInfoService.sendMessage(userId, message, integral);
        return getSuccessResponseVO(null);
    }
}
